package de.tudarmstadt.ukp.wikisniffer.userstudy.gui;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Panel;
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import de.tudarmstadt.ukp.wikisniffer.userstudy.Client;

public class RepeatGui extends AbstractGui {

	private String contentText;
	
	public void setText(String text){
		contentText = text;
	}

	@Override
	protected Panel getContentPanel() {
		Panel content = new Panel();
		content.setLayout(new BorderLayout());

		//open questions
		TextArea tfWelcome = new TextArea(contentText, 10, 50,  TextArea.SCROLLBARS_NONE);
		tfWelcome.setEditable(false);
		tfWelcome.setFont(new Font("Arial", Font.PLAIN, 18));
		
		content.add(tfWelcome, BorderLayout.CENTER);
		

		return content;
	}

	@Override
	public void open() {
		this.setBounds(Client.bigScreen);
		this.setTitle(this.getClass().getSimpleName());
		this.setLayout(new BorderLayout(30,0));

		TextArea tfWelcome = new TextArea(textFieldContent);
		tfWelcome.setEditable(false);
		this.add(tfWelcome, BorderLayout.NORTH);
		
		//add buttons
		this.add(getContentPanel(),BorderLayout.CENTER);
		
		this.setVisible(true);
		
		// add listener to detect window close button
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				//do nothing because participant should not be able to change test
				//Client.client.openStartGui(e);
			} 
		});
		
		Panel buttonPanel = new Panel();
		buttonPanel.setLayout(new GridLayout(2,1));
		
		//open questions
		Button bSubmit=new Button("Weiter");
		buttonPanel.add(bSubmit);
		bSubmit.addActionListener(
				new ActionListener(){
					public void actionPerformed(ActionEvent arg0) {
						Client.client.nextScreen();
					}
				});

		//open questions
		Button bRepeat=new Button("Wiederholen");
		buttonPanel.add(bRepeat);
		bRepeat.addActionListener(
				new ActionListener(){
					public void actionPerformed(ActionEvent arg0) {
						Client.client.repeatIntroduction();
					}
				});
		
		this.add(buttonPanel, BorderLayout.EAST);
	}
}
